package de.velvettear.squirrel.util;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import de.velvettear.squirrel.kernel.Statics;

public class LEDHelper {

	private static NotificationManager manager;
	private static Notification not;
	
	public static void startFlash(Context context, int hexColor, int pulseSpeed) {
		if (manager == null) {
			manager = (NotificationManager) context.getSystemService(Service.NOTIFICATION_SERVICE);
		}
		
		not = new Notification();
		not.ledARGB = hexColor;
		not.flags = Notification.FLAG_SHOW_LIGHTS;
		not.ledOnMS = pulseSpeed;
		not.ledOffMS = pulseSpeed;
		
		manager.notify(Statics.NOTIFICATION_ID_LED, not);		
	}
	
	public static void stopFlash(Context context) {
		if (manager == null) {
			manager = (NotificationManager) context.getSystemService(Service.NOTIFICATION_SERVICE);
		}
		
		if (not != null) {
			manager.cancel(Statics.NOTIFICATION_ID_LED);
			not = null;
		}
	}
	
}
